//
//  CWJavaScriptApiMap.m
//  CWDevelop
//
//  Created by LittoCats on 7/10/14.
//  Copyright (c) 2014 Littocats. All rights reserved.
//

#import "CWJavaScriptApiMap.h"

#import "CWMap.h"

@implementation CWJavaScriptApiMap

CWJavascriptApi(locate)
{
    [CWMap updateUserLocationWithHandler:^(NSDictionary *userLocationInfo) {
        [CWJSCALLBACK evaluateWithArguments:userLocationInfo, nil];
    } options:[params isEqualToString:@"WGS"] ? CWCoordinateOptionsWGS : [params isEqualToString:@"BD"] ? CWCoordinateOptionsBaidu : CWCoordinateOptionsGCJ];
}

//计算到 userlocation 的距离
CWJavascriptApi(distanceTo)
{
    [CWMap distanceFromUserLocationTo:params handler:^(id distance) {
        [CWJSCALLBACK evaluateWithArguments:distance, nil];
    }];
}

CWJavascriptApi(distance)
{
    id distance = [CWMap distanceFrom:params[@"from"] to:params[@"to"]];
    [CWJSCALLBACK evaluateWithArguments:distance, nil];
}
@end
